package demo1;

import java.util.Scanner;

public class Test {

    public static boolean isPalindrome(String s) {
        Scanner scanner = new Scanner(System.in);
        String str = scanner.nextLine();
        str = str.toLowerCase();
        String str1 = reverse(str);
        if(str.equals(str1)) {
            return true;
        }else {
            return false;
        }

    }

    private static String reverse (String str) {
        char[] ch = str.toCharArray();
        int left = 0;
        int right = ch.length - 1;
        while(left < right) {
            char tmp = ch[left];
            ch[left] = ch[right];
            ch[right] = tmp;
            left++;
            right--;
        }
        str = ch.toString();
        return str;

    }
    public static int countSegments(String s) {
        int length = s.length();
        int i = 0;
        if(length == 0) {
            return 0;
        }

        int count = 0;
        while( i < length) {

            if(s.charAt(i) == ' ' && s.charAt(i-1)  != ' ') {
                count++;

            }
            i++;
        }

        return count + 1;


    }


    public static void main(String[] args) {
//        System.out.println(isPalindrome("a"));
//        String str = "jja";
//        str.charAt(1);
        System.out.println(countSegments("had sjdj sdsc sdc"));
    }
}
